<template>
  <!-- 标题信息栏 -->
  <div class="title-bar">
    <div class="fileName" v-if="inputVisible">
      <p>{{ textName }}</p>
      <el-icon class="editPen" @click="editFileName()">
        <EditPen/>
      </el-icon>
    </div>

    <div class="fileName" v-else>
      <el-input v-model="textName" id="InputName" style="width: 240px"/>
      <el-icon class="editPen" @click="sureInput()">
        <Check/>
      </el-icon>
    </div>

    <div>
      <el-button type="primary" plain @click="edit()" v-if="!editFlag" :disabled="editable">编辑</el-button>
      <el-button type="primary" plain @click="save()" v-else>保存</el-button>
      <el-button type="primary" plain @click="share()">分享</el-button>
      <el-button type="primary" plain @click="derive()">导出</el-button>
    </div>
  </div>

  <!--  编辑内容-->
  <div ref="divRef">
    <div class="aie-container" v-loading.fullscreen.lock="fullscreenLoading">
      <div class="aie-container-header" v-show="showTool"></div>
      <div class="aie-container-main"></div>
      <div class="aie-container-footer" style="display: none"></div>
    </div>
  </div>

  <!--    分享弹窗-->
  <el-dialog v-model="shareVisible" title="分享" width="500">
    <el-form>
      <el-form-item label="设置有效期：">
        <el-radio-group v-model="settingType">
          <el-radio :value="7">7天有效</el-radio>
          <el-radio :value="30">30天有效</el-radio>
          <el-radio :value="100">永久有效</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="链接分享：">
        <el-input v-model="linkName" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="设置编辑：">
        <el-switch v-model="range" :change="editChange"/>
      </el-form-item>
      <el-form-item label="" v-show="range === true">
        <div style="width: 500px;display: flex;justify-content: space-between;align-items: center">
          <el-input v-model="editPassword" autocomplete="off" style="margin-right: 20px"/>
          <el-button type="primary" @click="getCode()">生成编辑码</el-button>
        </div>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="stopShare()">停止分享</el-button>
      </div>
    </template>
  </el-dialog>

  <!--    生成结果的选项框-->
  <el-drawer
      v-model="resultShow"
      title="AI记录"
  >
    <el-card class="consequence" shadow="always" v-for="(item,index) in resultList" :key="index">
      <template #header>
        <div class="card-header">
          <span>{{ item.title }}</span>
        </div>
      </template>
      <p>{{ item.cont }}</p>
    </el-card>
  </el-drawer>
</template>

<script setup lang="ts">
import {AiEditor} from "aieditor";
import "aieditor/dist/style.css"
import {onMounted, ref, watch} from "vue";
import Api from '@/api/index.ts'
import {onBeforeRouteUpdate, useRoute} from "vue-router";
import {ElMessage} from "element-plus";
import axios from "axios";

const divRef = ref();
let aiEditor: AiEditor | null = null;
// 图片的地址
const insertSrc = ref('')

onMounted(() => {
  aiEditor = new AiEditor({
    element: divRef.value as Element,
    image: {
      allowBase64: true,
      defaultSize: 350,
      uploadUrl: "http://1.92.137.88:86/dcLibrary/upload",
      uploader: (file, uploadUrl, headers, formName) => {
        const formData = new FormData();
        formData.append('file', file);
        return axios.post(uploadUrl, formData, {
          headers: {
            "Content-Type": "multipart/form-data",
            "token": localStorage.getItem('token')
          }
        })
            .then((res) => {
              if (res.data.code === 1) {
                ElMessage({
                  message: '图片上传成功',
                  type: 'success',
                })
                insertSrc.value = res.data.data
              } else {
                ElMessage({
                  message: '图片上传失败',
                  type: 'error',
                })
              }
            })
      },
      uploaderEvent: {
        onUploadBefore: (file, uploadUrl, headers) => {
          //监听图片上传之前，此方法可以不用回任何内容，但若返回 false，则终止上传
        },
        onSuccess: (file, response) => {
          return {
            "errorCode": 0,
            "data": {
              "src": insertSrc.value,
              "alt": ""
            }
          }
          //监听图片上传成功
          //注意：
          // 1、如果此方法返回 false，则图片不会被插入到编辑器
          // 2、可以在这里返回一个新的 json 给编辑器
        },
        onFailed: (file, response) => {
          //监听图片上传失败，或者返回的 json 信息不正确
        },
        onError: (file, error) => {
          //监听图片上传错误，比如网络超时等
        },
      },
      bubbleMenuItems: ["AlignLeft", "AlignCenter", "AlignRight", "delete", {
        id: "visit",
        title: "图片识别",
        icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M16 20V4H4V19C4 19.5523 4.44772 20 5 20H16ZM19 22H5C3.34315 22 2 20.6569 2 19V3C2 2.44772 2.44772 2 3 2H17C17.5523 2 18 2.44772 18 3V10H22V19C22 20.6569 20.6569 22 19 22ZM18 12V19C18 19.5523 18.4477 20 19 20C19.5523 20 20 19.5523 20 19V12H18ZM6 6H12V12H6V6ZM8 8V10H10V8H8ZM6 13H14V15H6V13ZM6 16H14V18H6V16Z\"></path></svg>",
        onClick: () => {
          getPic()
        }
      }]
    },
    placeholder: "点击输入内容...",
    content: '',
    toolbarKeys: ["undo", "redo", "brush", "eraser",
      "|", "heading", "font-family", "font-size",
      "|", "bold", "italic", "underline", "strike", "link", "code", "subscript", "superscript", "hr", "todo", "emoji",
      "|", "highlight", "font-color",
      "|", "align", "line-height",
      "|", "bullet-list", "ordered-list", "indent-decrease", "indent-increase", "break",
      "|", "image", "video", "attachment", "quote", "code-block", "table",
      "|", "source-code", "printer", "fullscreen",
    ],
    textSelectionBubbleMenu: {
      enable: true,
      items: [{
        id: "polish",
        title: "润色",
        icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M15 5.25C16.7949 5.25 18.25 3.79493 18.25 2H19.75C19.75 3.79493 21.2051 5.25 23 5.25V6.75C21.2051 6.75 19.75 8.20507 19.75 10H18.25C18.25 8.20507 16.7949 6.75 15 6.75V5.25ZM4 7C4 5.89543 4.89543 5 6 5H13V3H6C3.79086 3 2 4.79086 2 7V17C2 19.2091 3.79086 21 6 21H18C20.2091 21 22 19.2091 22 17V12H20V17C20 18.1046 19.1046 19 18 19H6C4.89543 19 4 18.1046 4 17V7Z\"></path></svg>",
        onClick: () => {
          polish()
        }
      }, {
        id: "continuation",
        title: "续写",
        icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M4 18.9997H20V13.9997H22V19.9997C22 20.552 21.5523 20.9997 21 20.9997H3C2.44772 20.9997 2 20.552 2 19.9997V13.9997H4V18.9997ZM16.1716 6.9997L12.2218 3.04996L13.636 1.63574L20 7.9997L13.636 14.3637L12.2218 12.9495L16.1716 8.9997H5V6.9997H16.1716Z\"></path></svg>",
        onClick: () => {
          continuation()
        }
      }, {
        id: "summary",
        title: "总结",
        icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M6.93912 14.0328C6.7072 14.6563 6.51032 15.2331 6.33421 15.8155C7.29345 15.1189 8.43544 14.6767 9.75193 14.5121C12.2652 14.198 14.4976 12.5385 15.6279 10.4537L14.1721 8.99888L15.5848 7.58417C15.9185 7.25004 16.2521 6.91614 16.5858 6.58248C17.0151 6.15312 17.5 5.35849 18.0129 4.2149C12.4197 5.08182 8.99484 8.50647 6.93912 14.0328ZM17 8.99739L18 9.99669C17 12.9967 14 15.9967 10 16.4967C7.33146 16.8303 5.66421 18.6636 4.99824 21.9967H3C4 15.9967 6 1.99669 21 1.99669C20.0009 4.99402 19.0018 6.99313 18.0027 7.99402C17.6662 8.33049 17.3331 8.66382 17 8.99739Z\"></path></svg>",
        onClick: () => {
          summary()
        }
      }, {
        id: "translate",
        title: "翻译",
        icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M5 15V17C5 18.0544 5.81588 18.9182 6.85074 18.9945L7 19H10V21H7C4.79086 21 3 19.2091 3 17V15H5ZM18 10L22.4 21H20.245L19.044 18H14.954L13.755 21H11.601L16 10H18ZM17 12.8852L15.753 16H18.245L17 12.8852ZM8 2V4H12V11H8V14H6V11H2V4H6V2H8ZM17 3C19.2091 3 21 4.79086 21 7V9H19V7C19 5.89543 18.1046 5 17 5H14V3H17ZM6 6H4V9H6V6ZM10 6H8V9H10V6Z\"></path></svg>",
        onClick: () => {
          translate()
        }
      }, {
        id: "compose",
        title: "智能排版",
        icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 8V20H19V8H5ZM5 6H19V4H5V6ZM20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22ZM7 10H11V14H7V10ZM7 16H17V18H7V16ZM13 11H17V13H13V11Z\"></path></svg>",
        onClick: () => {
          compose()
        },
      }, {
        id: "visiable",
        title: "数据可视化",
        icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M12.4 13.5333L17.4 20.2C17.5657 20.4209 17.5209 20.7343 17.3 20.9C17.2135 20.9649 17.1082 21 17 21H7C6.72386 21 6.5 20.7761 6.5 20.5C6.5 20.3918 6.53509 20.2865 6.6 20.2L11.6 13.5333C11.7657 13.3124 12.0791 13.2676 12.3 13.4333C12.3379 13.4618 12.3716 13.4954 12.4 13.5333ZM12 16.33L10 19H14L12 16.33ZM18 19V17H20V5H4V17H6V19H2.9918C2.44405 19 2 18.5554 2 17.9991V4.00087C2 3.44811 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44463 22 4.00087V17.9991C22 18.5519 21.5447 19 21.0082 19H18Z\"></path></svg>",
        onClick: () => {
          getVisiable()
        },
      },],
    },
  })

})

// 新建文档
const route = useRoute()
const textName = ref('未命名文档')
const textId = ref()

const editFlag = ref(false)
const editable = ref(false)

const showTool = ref(false)

onMounted(() => {
  if (route.query.source === 'detail') {
    textId.value = route.query.id;
    // 预览文档
    Api.lookDocu(textId.value).then((res) => {
      if (res.code === 1) {
        ElMessage.success('获取内容成功');
        if (aiEditor) {
          // 设置编辑器只读
          aiEditor.setEditable(false)
          // 内容赋值
          aiEditor.setContent(res.data.content);
          ElMessage.warning("当前为预览模式，如需编辑请切换编辑模式")
        }
      }
    })
    //   获取文档信息
    Api.getInfo(textId.value).then((res) => {
      if (res.code === 1) {
        textName.value = res.data.name;
      } else {
        ElMessage.error('获取文档信息失败');
      }
    })
  } else if (route.query.source === 'home') {
    showTool.value = true
    // 设置可编辑，显示保存按钮
    editFlag.value = true
    Api.addText(textName.value, '无', route.query.id, 'document_html').then((res) => {
      if (res.code === 1) {
        ElMessage.success('文本创建成功');
        textName.value = res.data.name;
        textId.value = res.data.id;
      } else {
        ElMessage.error('文本创建失败');
      }
    })
  } else if (route.query.source === 'share') {
    textId.value = route.query.id;
    if (route.query.pwd === 'false') {
      // 预览文档没有编辑权限
      Api.lookDocu(textId.value).then((res) => {
        if (res.code === 1) {
          ElMessage.success('获取内容成功');
          // 不能点击编辑
          editable.value = true;
          if (aiEditor) {
            // 设置编辑器只读
            aiEditor.setEditable(false)
            // 内容赋值
            aiEditor.setContent(res.data.content);
            ElMessage.warning("当前为预览模式，如需编辑请切换编辑模式")
          }
        }
      })
    } else if (route.query.pwd === 'true') {
      // 预览文档有编辑权限
      Api.lookDocu(textId.value).then((res) => {
        if (res.code === 1) {
          ElMessage.success('获取内容成功');
          if (aiEditor) {
            // 设置编辑器只读
            aiEditor.setEditable(false)
            // 内容赋值
            aiEditor.setContent(res.data.content);
            ElMessage.warning("当前为预览模式，如需编辑请切换编辑模式")
          }
        }
      })
    } else {
      ElMessage.error("分享有问题")
    }
  } else {
    console.log("other")
  }
})

// 点击编辑设置可编辑
const edit = () => {
  editFlag.value = true
  if (aiEditor) {
    // 设置编辑器可编辑
    aiEditor.setEditable(true)
    showTool.value = true
  }
}

// 点击产生加载按钮
const fullscreenLoading = ref(false)

//   润色续写
const result = ref('')
// 右侧弹窗
const resultShow = ref(false)
// 存放结果的列表
const resultList = ref([])
//进行润色的函数
const polish = () => {
  console.log(aiEditor.getSelectedText())
  let project = {}
  project.title = "润色"
  // 显示加载
  fullscreenLoading.value = true;
  let url = 'http://1.92.137.88:86/ai/polish' //访问后端接口的url
  let method = 'post'
  axios({
    method,
    url,
    data: {"cont": aiEditor.getSelectedText()},
  }).then(res => {
    if (res.data.code === 1) {
      ElMessage.success("润色成功")
      fullscreenLoading.value = false;
      resultShow.value = true;
      result.value = JSON.parse(res.data.data).answer;
      project.cont = result.value;
      resultList.value.push(project)
    } else {
      ElMessage.error("润色失败")
    }
  });
}

//进行续写
const continuation = () => {
  console.log(aiEditor.getSelectedText())
  let project = {}
  project.title = "续写"
  // 显示加载
  fullscreenLoading.value = true;
  let url = 'http://1.92.137.88:86/ai/continuation' //访问后端接口的url
  let method = 'post'
  axios({
    method,
    url,
    data: {"cont": aiEditor.getSelectedText()},
  }).then(res => {
    if (res.data.code === 1) {
      ElMessage.success("成功")
      fullscreenLoading.value = false;
      resultShow.value = true;
      result.value = JSON.parse(res.data.data).answer;
      project.cont = result.value;
      resultList.value.push(project)
    } else {
      ElMessage.error("失败")
    }
  });
}


// 总结
const summary = () => {
  console.log(aiEditor.getSelectedText())
  let project = {}
  project.title = "总结"
  // 显示加载
  fullscreenLoading.value = true;
  let url = 'http://1.92.137.88:86/ai/getabstract' //访问后端接口的url
  let method = 'post'
  axios({
    method,
    url,
    data: {"cont": aiEditor.getSelectedText()},
  }).then(res => {
    if (res.data.code === 1) {
      ElMessage.success("成功")
      fullscreenLoading.value = false;
      resultShow.value = true;
      result.value = JSON.parse(res.data.data).answer;
      project.cont = result.value;
      resultList.value.push(project)
    } else {
      ElMessage.error("失败")
    }
  });
}

// 翻译
const translate = () => {
  let project = {}
  project.title = "翻译"
  // 显示加载
  fullscreenLoading.value = true;
  let url = 'http://1.92.137.88:86/ai/translates' //访问后端接口的url
  let method = 'post'
  axios({
    method,
    url,
    data: {"cont": aiEditor.getSelectedText()},
  }).then(res => {
    if (res.data.code === 1) {
      ElMessage.success("成功")
      fullscreenLoading.value = false;
      resultShow.value = true;
      result.value = JSON.parse(res.data.data).answer;
      project.cont = result.value;
      resultList.value.push(project)
    } else {
      ElMessage.error("失败")
    }
  });
}

// 获取图片内容
const getPic = () => {
  resultList.value.push({cont: aiEditor.getSelectedText()})
  // 显示加载
  fullscreenLoading.value = true;
  let project = {}
  project.title = "图片识别"
  let url = 'http://1.92.137.88:86/ai/imgocr?userId=1&imgUrl=' + insertSrc.value //访问后端接口的url
  let method = 'post'
  axios({
    method,
    url,
  }).then(res => {
    if (res.data.code === 1) {
      fullscreenLoading.value = false;
      ElMessage({
        message: '图片识别成功',
        type: 'success',
      })
      let data = JSON.parse(res.data.data);
      let distinguish = '';
      for (let i = 0; i < data.content.length; i++) {
        distinguish += data.content[i] + ''
      }
      resultShow.value = true;
      result.value = distinguish;
      project.cont = result.value;
      resultList.value.push(project)
    } else {
      ElMessage.error("图片识别失败")
    }
  });
}

//智能排版
const compose = () => {
  console.log(aiEditor.getSelectedText())
  // if (aiEditor) {
  //   aiEditor.focus().insert("# 语文小天地一-V1（第1课时）\n\n---\n\n**封面设计**：\n\n🎉 **【语文小天地一-V1】** 📚  \n*开启智慧之门，遨游语言海洋的奇妙旅程！*  \n🌈 **第1课时：语文启蒙之旅** 🌟\n\n---\n\n**目录（创意排版）**：\n\n🔍 **第一章：汉字魔法初体验** 🧙‍♂️\n- 🖋️ **笔画奇遇记** —— 探秘汉字的基本骨架\n- 🎨 **书写小能手** —— 实战练习，秀出你的汉字风采\n\n🔊 **第二章：拼音王国探险** 🚀\n- 🎶 **声母大阅兵** —— 认识声音的领航员\n- 🌈 **韵母彩虹桥** —— 搭建发音的彩虹通道\n- 🎼 **声调小精灵** —— 掌握声音的起伏变化\n- 📚 **拼音小测验** —— 巩固学习，乐在其中\n\n💬 **第三章：词汇与句子的奇幻岛** 🏝️\n- 📖 **词语宝藏库** —— 收集智慧的光芒\n- 🌊 **句子造梦师** —— 用词语编织梦想的句子\n- 🗣️ **口语小剧场** —— 实战演练，让语言活起来\n\n🎨 **活动乐园** 🎈\n- 📖 **故事时光机** —— 穿越时空，聆听经典故事\n- 🎨 **古诗吟唱会** —— 诵读千年经典，品味文化韵味\n\n---\n\n**详细内容示例（第一章）**：\n\n🖋️ **笔画奇遇记**：\n\n```\n🌈 汉字，是中华文化的瑰宝。今天，我们就来一场笔画的奇妙探险吧！\n\n一横如桥，连接天地；一竖似松，挺拔坚韧。看，“人”字，简单两笔，却道尽了世间最复杂的情感与智慧。\n\n让我们拿起笔，按照正确的顺序，一笔一划地书写这些神奇的符号吧！记得，耐心与细心，是成为汉字大师的秘诀哦！\n```\n\n---\n\n**详细内容示例（第二章）**：\n\n🎶 **声母大阅兵**：\n\n```\n🎶 b、p、m、f... 这些声母，就像是我们声音的指挥官，引导着我们的发音之旅。\n\n听！bā——bā，像不像一只小猫在轻轻叫？pā——pā，是不是想起了小手拍掌的声音？\n\n来，跟我一起大声念出来，让声音在教室里回荡吧！\n```\n\n---\n\n**排版小贴士**：\n- 使用表情符号（Emoji）来增强视觉吸引力和趣味性。\n- 利用不同的颜色和字体样式来区分章节和内容块，使阅读更加轻松愉快。\n- 插入适量的图片或手绘插图，帮助学生更好地理解抽象概念。\n- 设计互动环节，如“小测验”、“小剧场”等，增加学生的参与度和学习兴趣。")
  // }
  // // 显示加载
  fullscreenLoading.value = true;
  let url = 'http://1.92.137.88:86/ai/getTypesetting' //访问后端接口的url
  let method = 'post'
  axios({
    method,
    url,
    data: {"cont": aiEditor.getSelectedText()},
  }).then(res => {
    console.log(res.data.data)
    if (res.data.code === 1) {
      ElMessage.success("成功")
      fullscreenLoading.value = false;
      result.value = JSON.parse(res.data.data).answer;
      if (aiEditor) {
        aiEditor.setContent(result.value)
      }
    } else {
      ElMessage.error("失败")
    }
  });
}

// 数据可视化
const getVisiable = () => {
  // // 显示加载
  fullscreenLoading.value = true;
  let url = 'http://1.92.137.88:86/ai/getVisualization' //访问后端接口的url
  let method = 'post'
  axios({
    method,
    url,
    data: {"cont": aiEditor.getSelectedText()},
  }).then(res => {
    console.log(res.data.data)
    if (res.data.code === 1) {
      ElMessage.success("成功")
      fullscreenLoading.value = false;
      result.value = JSON.parse(res.data.data).answer;
      if (aiEditor) {
        aiEditor.setContent(result.value)
      }
    } else {
      ElMessage.error("失败")
    }
  });
}

// 修改文件名
const inputVisible = ref(true)
const editFileName = () => {
  inputVisible.value = false
}

const sureInput = () => {
  inputVisible.value = true;
  Api.setInfo({id: textId.value, name: textName.value}).then((res) => {
    if (res.code === 1) {
      ElMessage({
        message: '修改成功',
        type: 'success',
      })
    } else {
      ElMessage.error('修改失败')
    }
  })
}

// 保存
const save = () => {
  if (aiEditor) {
    const content = aiEditor.getHtml()
    Api.saveText(textId.value, content).then((res) => {
      if (res.code === 1) {
        ElMessage({
          message: '保存成功',
          type: 'success',
        })
        if (aiEditor) {
          // 设置编辑器可编辑
          aiEditor.setEditable(false)
          showTool.value = false
        }
        editFlag.value = false
      } else {
        ElMessage.error('保存失败')
      }
    })
  }
}

// 分享
const shareVisible = ref(false)

const settingType = ref(100)

const linkName = ref('')

const range = ref(false)

const type = ref('CREATE_URL')

const editPassword = ref('')

const editChange = () => {
  range.value = !range.value
  const data = {id: textId.value, settingType: type.value, share: true, validityType: 'SEVEN_DAY'}
  if (type.value === 'PWD') {
    data.pwd = editPassword.value;
    Api.setShare(data).then(res => {
      console.log(res)
      shareFlag.value = false
    })
  } else {
    Api.setShare(data).then(res => {
      console.log(res)
      shareFlag.value = false
    })
  }
}

const shareFlag = ref(true)
const share = () => {
  shareVisible.value = true
  const data = {id: textId.value, settingType: type.value, share: true, validityType: 'SEVEN_DAY'}
  if (type.value === 'PWD') {
    data.pwd = editPassword.value;
    Api.setShare(data).then(res => {
      if (res.code === 1) {
        linkName.value = res.data.shareKey
      }
      shareFlag.value = false
    })
  } else {
    Api.setShare(data).then(res => {
      if (res.code === 1) {
        linkName.value = res.data.shareKey
      }
      shareFlag.value = false
    })
  }
}

// 生成密码后重新发起请求
const getCode = () => {
  const data = {id: textId.value, settingType: type.value, share: true, validityType: 'SEVEN_DAY'}
  if (type.value === 'PWD') {
    data.pwd = editPassword.value;
    Api.setShare(data).then(res => {
      if (res.code === 1) {
        linkName.value = res.data.shareKey
      }
      shareFlag.value = false
    })
  } else {
    Api.setShare(data).then(res => {
      if (res.code === 1) {
        linkName.value = res.data.shareKey
      }
      shareFlag.value = false
    })
  }
}

// 停止分享
const stopShare = () => {
  const data = {id: textId.value, settingType: type.value, share: false, validityType: 'SEVEN_DAY'}
  if (type.value === 'PWD') {
    data.pwd = editPassword.value;
    Api.setShare(data).then(res => {
      if (res.code === 1) {
        ElMessage({
          message: '停止分享成功',
          type: 'success',
        })
      }
      shareFlag.value = false
    })
  } else {
    Api.setShare(data).then(res => {
      if (res.code === 1) {
        ElMessage({
          message: '停止分享成功',
          type: 'success',
        })
      }
      shareFlag.value = false
    })
  }
}


// 导出
const derive = () => {

}
</script>

<style scoped lang="less">
@import "aieditor/dist/style.css";
//标题

.title-bar {
  width: 96%;
  height: 50px;
  font-size: 15px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;

  .fileName {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    font-size: 15px;

    .editPen {
      margin-left: 10px;
      font-size: 18px;
    }
  }
}

//编辑器修改
.aie-container-header {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.aie-container-main {
  width: 50vw;
  margin: 20px auto;
  font-size: 15px;
  z-index: 100;
  border: none;
}

//侧边弹出
.consequence {
  width: 90%;
  font-size: 16px;
  margin: 8px auto;
}

:deep(.el-card__body) {
  padding: 10px;
}
</style>
